<template>
  <div class="snow-page">
    <a-card title="企业详情" style="width: 99%" hoverable>
      <template #extra>
        <a-button size="mini" type="primary" @click="goBack">返回</a-button>
      </template>
      <a-descriptions title="" layout="vertical" bordered :column="5">
        <a-descriptions-item label="编码">{{ qiyeInfo.cq_company_code }}</a-descriptions-item>
        <a-descriptions-item label="名称">{{ qiyeInfo.name }}</a-descriptions-item>
        <a-descriptions-item label="简称">{{ qiyeInfo.cq_company_short_name }}</a-descriptions-item>
        <a-descriptions-item label="经纬度">{{ qiyeInfo.lon }},{{ qiyeInfo.lat }}</a-descriptions-item>
        <a-descriptions-item label="化学品登记系统编码">{{ qiyeInfo.cq_nrcc_code }}</a-descriptions-item>
        <a-descriptions-item label="工商注册地址">{{ qiyeInfo.cq_address_registry }}</a-descriptions-item>
        <a-descriptions-item label="生产场地地址">{{ qiyeInfo.cq_address_worksite }}</a-descriptions-item>
        <a-descriptions-item label="行政区域编码">{{ qiyeInfo.cq_area_code }}</a-descriptions-item>
        <a-descriptions-item label="法定代表人">{{ qiyeInfo.cq_representative_person }}</a-descriptions-item>
        <a-descriptions-item label="企业负责人">{{ qiyeInfo.cq_responsible_person }}</a-descriptions-item>
        <a-descriptions-item label="企业负责人电话">{{ qiyeInfo.cq_responsible_phone }}</a-descriptions-item>
        <a-descriptions-item label="安全负责人">{{ qiyeInfo.cq_safety_responsible_person }}</a-descriptions-item>
        <a-descriptions-item label="安全负责人电话">{{ qiyeInfo.cq_safety_responsible_phone }}</a-descriptions-item>
        <a-descriptions-item label="安全值班电话">{{ qiyeInfo.cq_duty_phone }}</a-descriptions-item>
        <a-descriptions-item label="安全生产标准化等级">{{ qiyeInfo.cq_safety_standard_grad_name }}</a-descriptions-item>
        <a-descriptions-item label="安全生产许可证编号">{{ qiyeInfo.cq_safety_license_no }}</a-descriptions-item>
        <a-descriptions-item label="安全生产许可证有效期开始日期">{{ qiyeInfo.cq_safety_license_start }}</a-descriptions-item>
        <a-descriptions-item label="安全生产许可证有效期结束日期">{{ qiyeInfo.cq_safety_license_end }}</a-descriptions-item>
        <a-descriptions-item label="邮政编码">{{ qiyeInfo.cq_post_code }}</a-descriptions-item>
        <a-descriptions-item label="网址">{{ qiyeInfo.cq_web_site }}</a-descriptions-item>
        <a-descriptions-item label="描述">{{ qiyeInfo.description }}</a-descriptions-item>
        <a-descriptions-item label="成立日期">{{ formatTime(qiyeInfo.cq_establish_date) }}</a-descriptions-item>
        <a-descriptions-item label="所属化工园名称">{{ qiyeInfo.cq_industrial_park_name }}</a-descriptions-item>
        <a-descriptions-item label="职工人数">{{ qiyeInfo.cq_people_employee }}</a-descriptions-item>
        <a-descriptions-item label="从业人员人数">{{ qiyeInfo.cq_people_practitioner }}</a-descriptions-item>
        <a-descriptions-item label="企业规模">{{ qiyeInfo.cq_company_scale_name }}</a-descriptions-item>
        <a-descriptions-item label="企业类型">{{ qiyeInfo.cq_company_type_name }}</a-descriptions-item>
        <a-descriptions-item label="经济类型">{{ qiyeInfo.cq_economic_type_name }}</a-descriptions-item>
        <a-descriptions-item label="所属行业门类">{{ qiyeInfo.cq_industry_category_name }}</a-descriptions-item>
        <a-descriptions-item label="所属行业大类">{{ qiyeInfo.cq_industry_class_name }}</a-descriptions-item>
        <a-descriptions-item label="统一社会信用代码">{{ qiyeInfo.cq_social_credit_code }}</a-descriptions-item>
        <a-descriptions-item label="营业执照经营范围">{{ qiyeInfo.cq_business_scope }}</a-descriptions-item>
        <a-descriptions-item label="是否在化工园区内">{{
          qiyeInfo.cq_in_industrial_park == 1 ? "是" : "否`"
        }}</a-descriptions-item>
        <a-descriptions-item label="危险化学品作业人员人数">{{ qiyeInfo.cq_people_hazard }}</a-descriptions-item>
        <a-descriptions-item label="特种作业人员人数">{{ qiyeInfo.cq_people_operation }}</a-descriptions-item>
        <a-descriptions-item label="最后修改时间">{{ formatTime(qiyeInfo.cq_update_date) }}</a-descriptions-item>
      </a-descriptions>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from "vue";
import {getDictBycodeAPI, getDictBycode3API} from "@/api/modules/dictionary/index";
const router = useRouter();

const qiyeInfo = ref({}) as any;

onMounted(() => {
  getDictBycodeAPIFun();
  getDictBycodeAPIFun2();
  getDictBycodeAPIFun3();
  getDictBycodeAPIFun4();
  getDictBycodeAPIFun6();
  let userInfo = JSON.parse(localStorage.getItem("user-info") as string);
  qiyeInfo.value = userInfo.sharedObject;
});

function format387(val) {
  let obj = optinos387.value.filter(e => {
    return e.id == parseInt(val);
  });
  return obj[0].name;
}

const optinos387 = ref([]);

async function getDictBycodeAPIFun() {
  let res = await getDictBycodeAPI(387);
  if (res.status == 2) {
    optinos387.value = res.data;
    qiyeInfo.value.cq_company_scale_name = format387(qiyeInfo.value.cq_company_scale);
  }
}
const optinos392 = ref([]);
async function getDictBycodeAPIFun2() {
  let res = await getDictBycodeAPI(392);
  if (res.status == 2) {
    optinos392.value = res.data;
    qiyeInfo.value.cq_company_type_name = format392(qiyeInfo.value.cq_company_type);
  }
}

function format392(val) {
  let obj = optinos392.value.filter(e => {
    return e.id == parseInt(val);
  });
  return obj[0].name;
}

const optinos396 = ref([]);
async function getDictBycodeAPIFun3() {
  let res = await getDictBycodeAPI(396);
  if (res.status == 2) {
    optinos396.value = res.data;
    qiyeInfo.value.cq_economic_type_name = format396(qiyeInfo.value.cq_economic_type);
  }
}

function format396(val) {
  let obj = optinos396.value.filter(e => {
    return e.id == parseInt(val);
  });
  return obj[0].name;
}

function format431(val) {
  let obj = optinos431.value.filter(e => {
    return e.id == parseInt(val);
  });
  return obj[0].name;
}

const optinos431 = ref([]);
function getDictBycodeAPIFun4() {
  getDictBycodeAPI(431).then(res => {
    if (res.status == 2) {
      optinos431.value = res.data;
      qiyeInfo.value.cq_industry_category_name = format431(qiyeInfo.value.cq_industry_category);

      let obj = optinos431.value.filter(e => {
        return e.id == qiyeInfo.value.cq_industry_category;
      });
    
      
      if (obj.length > 0) {
        getDictBycodeAPIFun5(obj[0].code);
      }
    }
  });
}
const optinos431_1 = ref([]);
async function getDictBycodeAPIFun5(code) {
  let paged = 1;
  let pageSize = 100;
  let obj = {
    p_code: code
  };
  let res = await getDictBycode3API(paged, pageSize, obj);

  
  if (res.status == 2) {
    optinos431_1.value = res.data.data;
    qiyeInfo.value.cq_industry_class_name = format431_1(qiyeInfo.value.cq_industry_class);
  }
}

function format500(val) {
  let obj = optinos500.value.filter(e => {
    return e.id == parseInt(val);
  });
  return obj[0].name;
}

const optinos500 = ref([]);
async function getDictBycodeAPIFun6() {
  let res = await getDictBycodeAPI(500);
  if (res.status == 2) {
    optinos500.value = res.data;
   qiyeInfo.value.cq_safety_standard_grad_name =  format500(qiyeInfo.value.cq_safety_standard_grad);
  }
}


function format431_1(val) {
  let obj = optinos431_1.value.filter(e => {
    return e.id == parseInt(val);
  });
 
  
  return obj[0].name;
}

function formatTime(specificTimestamp) {
  // 创建一个Date对象
  if (specificTimestamp) {
    let date = new Date(specificTimestamp);

    let year = date.getFullYear();
    let month = date.getMonth() + 1; // 月份从0开始，需要加1
    let day = date.getDate();

    // 格式化日期字符串
    let formattedDate = `${year}-${month < 10 ? "0" : ""}${month}-${day < 10 ? "0" : ""}${day}`;

    return formattedDate;
  }
}
function goBack() {
  router.back();
}
</script>





<style lang="scss" scoped></style>
